package io.gitee.yth.design.pattern.test.core.pattern.structural.facade.code;


import io.gitee.yth.design.pattern.test.core.pattern.structural.facade.code.subsystem.DVDPlayer;
import io.gitee.yth.design.pattern.test.core.pattern.structural.facade.code.subsystem.Popcorn;
import io.gitee.yth.design.pattern.test.core.pattern.structural.facade.code.subsystem.Projector;
import io.gitee.yth.design.pattern.test.core.pattern.structural.facade.code.subsystem.Screen;
import io.gitee.yth.design.pattern.test.core.pattern.structural.facade.code.subsystem.Stereo;
import io.gitee.yth.design.pattern.test.core.pattern.structural.facade.code.subsystem.TheaterLight;

/**
 * 外观模式
 *
 * @author yth
 * @since 2023-04-26-23:50
 */
public class HomeTheaterFacade {

    private final DVDPlayer dvdPlayer;
    private final Popcorn popcorn;
    private final Projector projector;
    private final Screen screen;
    private final Stereo stereo;
    private final TheaterLight theaterLight;

    public HomeTheaterFacade() {
        dvdPlayer = DVDPlayer.getInstance();
        popcorn = Popcorn.getInstance();
        projector = Projector.getInstance();
        screen = Screen.getInstance();
        stereo = Stereo.getInstance();
        theaterLight = TheaterLight.getInstance();
    }

    public void ready() {
        System.out.println("----------ready----------");
        theaterLight.on();
        screen.up();
        stereo.on();
        projector.on();
        dvdPlayer.on();
        popcorn.on();
        popcorn.run();
    }

    public void play() {
        System.out.println("----------play----------");
        theaterLight.dim();
        projector.focus();
        stereo.turnUp();
        dvdPlayer.play();
    }

    public void pause() {
        System.out.println("----------pause----------");
        dvdPlayer.pause();
        stereo.turnDown();
        theaterLight.bright();
    }

    public void end() {
        System.out.println("----------end----------");
        popcorn.off();
        dvdPlayer.off();
        projector.off();
        screen.down();
        stereo.off();
        theaterLight.off();
    }

}
